import { defineStore } from 'pinia'
import { GlobalState } from '@/store/interface/index'
import PiniaPersistConfig from '@/config/piniaPersist'

export const useUserStore = defineStore('global', {
  state: (): GlobalState => ({
    // 布局模式 (垂直：vertical | 水平：horizontal | 混合：mixture | 双列：doubleRow)
    layout: 'vertical'
  }),
  getters: {},
  actions: {
    setGlobalState(...args) {
      // 第一个字段是store中定义的字段，第二个是值，this.$patch给参数1字段赋值参数2
      this.$patch({ [args[0]]: args[1] })
    }
  },
  persist: PiniaPersistConfig('global', [])
})
